#ifndef __RTC_H
#define __RTC_H

#include <RTL.h>

#define TICKS_PER_HOUR						36000000000		//количество тиков в часе

#define TICKS_2001								631139040000000000

typedef struct 
{
		U16 Year;    /* Year value - [0,4095] */
		U8 	Mon;     /* Month value - [1,12] */
		U8 	Mday;    /* Day of the month value - [1,31] */
		U8 	Hour;    /* Hour value - [0,23] */
		U8 	Min;     /* Minute value - [0,59] */
		U8 	Sec;     /* Second value - [0,59] */
}DateTimeT;

typedef struct {
		DateTimeT date_time;	
		U32 RTC_Mday;    /* Day of the month value - [1,31] */
    U32 RTC_Wday;    /* Day of week value - [0,6] */
    U32 RTC_Yday;    /* Day of year value - [1,365] */
} RTCTime;




#define CCR_CLKEN	0x01

/*
	Глобальные переменные
*/
extern U8 monthes[];

/*
	Прототипы функций
*/
void rtc_init(void);
void rtc_set_time(DateTimeT dt);
DateTimeT rtc_get_time( void );
U8 rtc_set_time_in_ticks(U64 ticks);
U64 time_to_ticks(DateTimeT dt);
DateTimeT ticks_to_time(U64 ticks);
U16 get_Yday(DateTimeT dt);
U64  rtc_get_time_in_ticks(void);
void rtc_time_clear(DateTimeT *d);

#endif 
